/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.workforce.common.tags;

import java.lang.reflect.Method;
import javax.servlet.jsp.JspException;
import javax.servlet.jsp.JspWriter;
import javax.servlet.jsp.PageContext;
import org.workforce.util.Utils;

/**
 *
 * @author neo
 */
public class IdFieldTag extends FieldBaseTag {

    @Override
    public int doStartTag() throws JspException {
        try {
            JspWriter out = pageContext.getOut();

            StringBuffer s = new StringBuffer();
            s.append("<input type=\"text\" ");
            if (id != null) {
                s.append("id=\"").append(id).append("\" ");
            } else {
                s.append("id=\"").append(name).append("\" ");
            }
            if (name != null) {
                s.append("name=\"").append(name).append("\" ");
            } else {
                s.append("name=\"").append(id).append("\" ");
            }
            s.append("value=\"").append(Utils.generateId()).append("\" ");
            if (sClass != null) {
                s.append("class=\"").append(sClass).append("\" ");
            }
            if(style != null) {
                s.append("style=\"").append(style).append("\" ");
            }
            s.append(" readonly=\"true\">");
            out.print(s.toString());
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        return SKIP_BODY;
    }
}
